package excise;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

/**
 * @author CoderXshuai
 */
public class Call {
    public static void main(String[] args) throws Exception {
        ExecutorService pool = Executors.newCachedThreadPool();
        CallImp callImp = new CallImp();
        Future future1 = pool.submit(callImp);
        Future future2 = pool.submit(callImp);
        System.out.println(future1.get().toString());
        System.out.println(future2.get().toString());
        System.out.println(callImp.getID());
    }
}

class CallImp implements Callable {
    private int id = 10;
    private int ID=6;

    @Override
    public Object call() throws Exception {
        synchronized (this) {
            id = 6;
            ID=7;
            return --id;
        }
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getID() {
        return ID;
    }

    public void setID(int ID) {
        this.ID = ID;
    }
}
